//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#include "../ArrayCursor.h"

using namespace Native::System;

CArrayCursor::CArrayCursor() :
    _index(INEXISTENT)
{
}

CArrayCursor::CArrayCursor(ARRAY_CURSOR& that) :
    CObject(that),
    _index(that._index)
{
}

CArrayCursor::CArrayCursor(ARRAY_CURSOR&& that) :
    CObject(that),
    _index(that._index)
{
}

CArrayCursor::CArrayCursor(size_t index) :
    _index(index)
{
}

bool CArrayCursor::operator==(ARRAY_CURSOR& rvalue) const
{
    return _index == rvalue._index;
}

bool CArrayCursor::operator!=(ARRAY_CURSOR& rvalue) const
{
    return !operator==(rvalue);
}

bool CArrayCursor::Exist() const
{
    return _index != INEXISTENT;
}

bool CArrayCursor::Forward()
{
    if (Exist()) {
        _index++;

        return true;
    } else {
        return false;
    }
}

bool CArrayCursor::Back()
{
    if (Exist()) {
        _index--;

        return true;
    } else {
        return false;
    }
}

ARRAY_CURSOR& CArrayCursor::operator=(ARRAY_CURSOR& rvalue)
{
    _index = rvalue._index;

    return *this;
};
